package org.ts.wifi;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;

public class SysContext {
    public final static int SOCKET_PORT = 9100;
    public final static int SOCKET_TIMEOUT = 30000;
    public final static int SOCKET_VERIFY = 27;
    public final static int SOCKET_RETURN_FAIL = -1;
    public final static int SOCKET_RETURN_PASS = 0;
    
    public static String getLocalIpAddress() {   
	String ipaddr = "";
	        try {       
	        for (Enumeration<NetworkInterface> en = NetworkInterface       
	                   .getNetworkInterfaces(); en.hasMoreElements();) {       
	                NetworkInterface intf = en.nextElement();       
	                for (Enumeration<InetAddress> enumIpAddr = intf       
	                        .getInetAddresses(); enumIpAddr.hasMoreElements();) {       
	                    InetAddress inetAddress = enumIpAddr.nextElement();       
	                    if (!inetAddress.isLoopbackAddress()) {       
	                	ipaddr =  inetAddress.getHostAddress();
	                	//ipaddr =  inetAddress.getHostName().toString();      
	                   }       
	               }       
	            }       
	        } catch (SocketException ex) {     
	           
//	            Log.e("WifiPreference IpAddress", ex.toString());       
	        } 
	        return ipaddr;
    }
    

}
